package mipo.top.users.controller;


import mipo.top.base.util.JsonResult;
import mipo.top.base.util.PageUtil;
import mipo.top.users.Vo.LogininfoVo;
import mipo.top.users.domain.Logininfo;
import mipo.top.users.query.LogininfoQuery;
import mipo.top.users.service.ILogininfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/logininfo")
public class LogininfoController {

    @Autowired
    private ILogininfoService logininfoService;

    @GetMapping
    public List<Logininfo> sad(){
        return logininfoService.findall();
    }

    @PutMapping
    public JsonResult su(@RequestBody Logininfo logininfo){
        try {
            if(logininfo.getId()==null){
                logininfoService.save(logininfo);
            }else{
                logininfoService.update(logininfo);
            }
            return JsonResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.me().setMsg("错误数据");
        }
    }

    @DeleteMapping("/{id}")
    public void adw(@PathVariable("id") Long id){
        logininfoService.remove(id);
    }

    @PostMapping
    public PageUtil<Logininfo> asp(@RequestBody LogininfoQuery logininfoQuery){
        return logininfoService.queryData(logininfoQuery);
    }
    @PatchMapping
    private void bacthDel(@RequestBody List<Long> ids){
        logininfoService.patchremove(ids);
    }
}
